﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DwarfParser
{
    static class MyMaps // TODO: remove this class
    {
        private static Dictionary<AstType.Type, string> types = new Dictionary<AstType.Type, string>() 
        {
            {AstType.Type.BOOLEAN,    "bool"},
            {AstType.Type.INT,        "int"},
            {AstType.Type.INT_ARR,    "int[]"},
            {AstType.Type.VOID,       "void"},
            {AstType.Type.STRING,     "String"},
            {AstType.Type.STRING_ARR, "String[]"}
        };

        public static string AstTypeToString(AstType.Type t)
        {
            return types[t];
        }

        public static AstType.Type StringToAstType(string str)
        {
            if (!types.ContainsValue(str))
            {
                throw new Exception("This code path should be unreachable. Error TYPE_DECL token attribute.");
            }
            
            return types.First((x) => x.Value == str).Key;
        }
    }
}
